load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "cardinality",
    srcs = [
        "cross_estimation.go",
        "join.go",
        "ndv.go",
        "pseudo.go",
        "row_count_column.go",
        "row_count_index.go",
        "row_size.go",
        "selectivity.go",
        "trace.go",
    ],
    importpath = "github.com/pingcap/tidb/planner/cardinality",
    visibility = ["//visibility:public"],
    deps = [
        "//expression",
        "//kv",
        "//parser/ast",
        "//parser/format",
        "//parser/model",
        "//parser/mysql",
        "//planner/property",
        "//planner/util",
        "//planner/util/debugtrace",
        "//sessionctx",
        "//sessionctx/stmtctx",
        "//statistics",
        "//tablecodec",
        "//types",
        "//types/parser_driver",
        "//util/chunk",
        "//util/codec",
        "//util/collate",
        "//util/logutil",
        "//util/mathutil",
        "//util/ranger",
        "//util/set",
        "//util/tracing",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@org_golang_x_exp//maps",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "cardinality_test",
    timeout = "short",
    srcs = [
        "main_test.go",
        "row_count_test.go",
        "row_size_test.go",
        "selectivity_test.go",
        "trace_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":cardinality"],
    flaky = True,
    shard_count = 32,
    deps = [
        "//config",
        "//domain",
        "//executor",
        "//expression",
        "//infoschema",
        "//kv",
        "//parser",
        "//parser/model",
        "//parser/mysql",
        "//planner/core",
        "//session",
        "//sessionctx",
        "//sessionctx/stmtctx",
        "//sessionctx/variable",
        "//statistics",
        "//statistics/handle",
        "//testkit",
        "//testkit/testdata",
        "//testkit/testmain",
        "//testkit/testsetup",
        "//types",
        "//util/codec",
        "//util/collate",
        "//util/mock",
        "//util/ranger",
        "//util/tracing",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_goleak//:goleak",
    ],
)
